<?php
namespace Admin\Controller;
use Think\Controller;
class CoachController extends BaseController {
   
public function coachList(){
        //14110100412金永春
  
        $coachmodel =M('coach'); 

        $pageSize=5;//每页显示的数据个数
       // $records=$coachmodel->count(); //查询数据表中数据的总个数
        $Page = new \Think\Page($records,$pageSize);//实例化分页类，传入总数和每页显示的数量
        $list=$coachmodel->order('coach_id asc')->limit($Page->firstRow,$pageSize)->select();//进行分页数据查询
        // dump($list);
        // exit();
        //$comments=$commentsmodel->order('comments_id asc')->select();
        //$this->comments=$comments;
        $page1=$Page->show();//分页显示输出
        $this->assign(array('coach'=>$list,'page1'=>$page1));//用数组的方式赋值数据集，赋值分页输出
 $coach = $coachmodel->where('coach_state=1')->select();
        //调用视图层显示数据
        $this->coach=$coach;
        $this->display();//输出模板

       
       
       /* $this->link=$Page->show();
        $this->qrcodeList=$goods->where($goodsData)->order("id desc")->limit($Page->firstRow,$pageSize)->select();*/
    }
    public function changestate($coach_id,$coach_dashi){
        $coachmodel=M('coach');//14110100412金永春
        $coachmodel->coach_dashi=($coach_dashi+1)%2;
        if(false!==$coachmodel->where("coach_id=$coach_id")->save()){
            //false不恒等用于精确和0进行比较
            //save保存，将值保存到数据表中。
            $this->success('状态修改成功！');
        }else{
            $this->error('状态修改失败');
        }
    }
    public function search($coach_id){
       
       $coachmodel =M('coach');
        $coach=$coachmodel->where("coach_id=$coach_id")->select();
        $this->coach=$coach;
        $this->display(); 
    } 

}
?>